const downloadFile = function (res, fileName) {
    const _blob = new Blob([res]);
    const _downElement = document.createElement('a');
    const _href = URL.createObjectURL(_blob);
    const _nameStr = fileName;

    _downElement.href = _href;  // 下载链接
    _downElement.download = _nameStr;   // 文件名

    _downElement.click();   // 触发点击下载

    URL.revokeObjectURL(_href);  // 释放 blob 对象
};

export default downloadFile;